package com.brooks.demo;

/**
 * join方法的使用
 * @Author mihutu
 * @Date 2020/10/16 11:12
 * @Version 1.0
 */
public class DemoThread4 {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            System.out.println("t1");
        });
        Thread t2 = new Thread(()->{
            try {
                //join方法会等待join的这个线程先执行完再执行后面的
                t1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t2");
        });
        t2.start();
        t1.start();
        //t1.join();
//        t2.join();
    }
}